package com.xmy.servlet;

import com.xmy.service.UserService;
import com.xmy.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class UserInfoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        UserService us = new UserServiceImpl();
        PrintWriter out = response.getWriter();
        String method = request.getParameter("method");
        if(method.equals("updateInfo")){
            String column = request.getParameter("column");
            String id = request.getParameter("id");
            String updateValue = request.getParameter("updateValue");
            int i = us.updateUserInfo(column, updateValue, Integer.parseInt(id));
            out.print(i);
            out.flush();
            out.close();
        }else if(method.equals("updatePwd")){

        }
    }
}
